package com.controller;

import com.alibaba.fastjson.JSON;
import com.entity.PostsEntity;
import com.service.PostsService;
import com.service.serviceImpl.PostsServiceImpl;
import com.sun.corba.se.spi.activation.Server;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/app/getByPostsIdServlet")
public class getByPostsIdServlet extends HttpServlet {
    private PostsService postsService = new PostsServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        PostsEntity bypostsId = postsService.getBypostsId(id);
        String JSONMap = JSON.toJSONString(bypostsId);
        response.getWriter().write(JSONMap);
    }
}
